package javafx.com;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
 * @Classname main
 * @Date 2021/09/21 11:13
 * @Author by yx
 * @Description :
 */
public class main extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {

        Button button1 = new Button("button1");
        Button button2 = new Button("button2");
        Button button3 = new Button("button3");
        Button button4 = new Button("button4");
        Button button5 = new Button("button5");

        // 默认居中显示
        StackPane stackPane = new StackPane();
        stackPane.setStyle("-fx-background-color: #EE6AA7");

        // 由于stackPane默认居中显示,单纯设置间距没有效果,需要设置一下默认显示方式
        stackPane.setPadding(new Insets(100));
        stackPane.setAlignment(Pos.TOP_LEFT);
        StackPane.setMargin(button1, new Insets(100));

        stackPane.getChildren().addAll(button1, button2, button3, button4, button5);

        stackPane.getChildren().forEach((item) -> {
            System.out.println(item);
        });


        Scene scene = new Scene(stackPane);
        primaryStage.setScene(scene);
        primaryStage.setWidth(800);
        primaryStage.setHeight(800);
        primaryStage.setTitle("javafx");
        primaryStage.show();
    }
}
